package com.stox.ui.javafx.charting.widget.axis;

import javafx.geometry.Side;
import javafx.geometry.VPos;
import javafx.scene.layout.Pane;
import javafx.scene.text.TextAlignment;

import com.stox.ui.javafx.charting.widget.Chart;

public class AbstractVerticalAxis extends AbstractAxis<Chart<?>>{

	public static final double width = 30;
	
	public static final double padding = 10;

	public AbstractVerticalAxis() {
		prefWidth(width);
		setWidth(width);
		gc.setTextBaseline(VPos.CENTER);
	}
	
	public void update() {
		super.update();
		if(null != getChart() && null != getChart().getCenter()) {
			Pane center = (Pane)getChart().getCenter();
			setHeight(center.getHeight());
		}
		gc.strokeLine(getSide().equals(Side.LEFT) ? getWidth() : 0, 0, getSide().equals(Side.LEFT) ? getWidth() : 0, getHeight());
	}
	
	@Override
	public void setSide(Side side) {
		super.setSide(side);
		gc.setTextAlign(Side.LEFT.equals(side) ? TextAlignment.LEFT : TextAlignment.RIGHT);
	}

}
